package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Dorm;
import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.mapper.DormMapper;
import com.neuedu.studentmanage.service.DormService;

@Service
@Transactional
public class DormServiceImpl implements DormService {

	@Autowired
	private DormMapper dormMapper;

	@Override
	public List<Dorm> findListByPager(Pager<Dorm> pager) {

		return dormMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Dorm> pager) {

		return dormMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Dorm object) {
		Result result = new Result(false, "新增宿舍信息失败");
		boolean ret = dormMapper.add(object);
		if (ret) {
			result = new Result(true, "新增宿舍信息成功");
		}
		return result;
	}

	@Override
	public Result edit(Dorm object) {
		Result result = new Result(false, "修改宿舍信息失败");
		boolean ret = dormMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改宿舍信息成功");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Dorm> ids) {
		Result result = new Result(false, "删除宿舍信息失败");
		boolean ret = dormMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除宿舍信息成功");
		}
		return result;
	}

	@Override
	public List<Dorm> findAll() {

		return dormMapper.findAll();
	}

}
